
//进度条
$(function(){
	var wid=$('.ipttext').val();
	$('.stepBar_stepProcess').width(wid+'%');
	if(wid>=0){$('#point0').children().addClass("active");}
	if(wid>=25){$('#point1').children().addClass("active");}
	if(wid>=50){$('#point2').children().addClass("active");}
	if(wid>=75){$('#point3').children().addClass("active");}
	if(wid>=100){$('#point4').children().addClass("active");}
});
$(function(){
	var wid=$('.ipttext').val();
	if(wid<75){$('#point4').children().addClass("sleep");}
	if(wid<50){$('#point3').children().addClass("sleep");}
	if(wid<25){$('#point2').children().addClass("sleep");}
	if(wid<=0){$('#point1').children().addClass("sleep");}
});
/*测试用例*/
$(function(){
	$('.ipttext').change(function(){
		var wid=$(this).val();
		$('.stepBar_stepProcess').width(wid+'%');
		if(wid>=0){$('#point0').children().addClass("active");}
		if(wid>=25){$('#point1').children().addClass("active");}
		if(wid>=50){$('#point2').children().addClass("active");}
		if(wid>=75){$('#point3').children().addClass("active");}
		if(wid>=100){$('#point4').children().addClass("active");}
	});
});

//表单验证
function check(form) {
	var errorStr1="";
	var errorStr2="";
    var account = document.login.account.value.trim();
    var password = document.login.password.value.trim();
//    var role = document.login.role.value;
    var errorAct = $("#account_error");
    var errorPsw = $("#password_error");
    if (!account || account.length < 0) {errorStr1="账号不能为空";}
    else if (!password || password.length < 0) {errorStr2="密码不能为空！";}
    else if (!/^[0-9]{1,12}$/.test(account)) {errorStr1="账号必须为数字";}
    if (errorStr1==""&&errorStr2=="") {return true;}
    else{
    	errorAct.text(errorStr1);
    	errorPsw.text(errorStr2);
    	return false;
    }
}
//单选框复选框
$(function(){
	$('.radio').on("click",function(){
		var rd_prt=$(this).parent();
		//rd_prt.removeClass('active').eq($(this).index()).addClass('active');
		rd_prt.addClass("active").siblings().removeClass("active");
		//rd_prt.css({'backgroundColor':'#787d82'}).siblings().css({'backgroundColor':'#ccc'});
	});
	$(".checkbox").on("click",function(){
		var cb_prt=$(this).parent();
		cb_prt.hasClass("active")? cb_prt.removeClass("active"):cb_prt.addClass("active");
    	//cb_prt.css({'backgroundColor':'#787d82'})? cb_prt.css({'backgroundColor':'#ccc'}): cb_prt.css({'backgroundColor':'#787d82'});
	});
});
//试题提交验证
function checktext(form) {
	var nullAry='：';
	var account = document.temperature.temp_size.value.trim();
	console.log(account);
	for(var i=1;i<=account;i++){
		var flag=0;
		var textval = document.getElementsByName(i);
		for(var j=0;j<textval.length;j++){
			if(textval[j].checked){flag=1;break;}
		}
		if(flag==0){nullAry+=i+'、';}
		console.log(i+'+*+*+*+'+nullAry+'+*+*+*+'+flag);
	}
	if(nullAry=='：'){return true;}
	else{alert("未做的题目有"+nullAry);return false;}
}